# 随机生成geojson数据
# coordinates在 119.5-121.2 30.47-32.02之间
# properties中随机生成一个字段 id, id用uuid生成
# 生成100000条数据
# 写入本地json文件

import random
import json
import os
import uuid
# 设置随机种子
random.seed(42)

# 生成100000条数据
geojson = {
    "type": "FeatureCollection",
    "features": []
}

for i in range(300000):
    # 随机生成一个id
    id = str(uuid.uuid4())
    # 随机生成一个coordinates
    coordinates = [random.uniform(119.5, 121.2), random.uniform(30.47, 32.02)]
    # 生成一个geojson数据
    feature = {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": coordinates
        },
        "properties": {
            "id": id
        }
    }
    geojson['features'].append(feature)

# 写入本地json文件
with open('geojson_data.json', 'w', encoding='utf-8') as f:
    json.dump(geojson, f, ensure_ascii=False)

